const   char RevNum[20] =  {    // interface no.
// '-----------------'
  "EFI control 18Fv0.2" //; MS-II sends a null at 20th byte.
// 123456789.123456789.
};

const	char Signature[32] = {            // code version
// '-----------------------------' 32	
  "* EFI embedded code by Astral *"
};

#define NO_TBLES    3
#define NO_FMAPS 	12
#define NO_SMAPS 	12
#define NO_FRPMS 	12
#define NO_SRPMS 	12
#define NO_INJ		2
#define NO_TEMPS 	10
#define NO_TPS_DOTS   4
#define NO_MAP_DOTS   4
#define CRANK_RPM   400
#define NPORT    2
#define NO_COILCHG_PTS  5


//======= MegaSquirt comunication ==================

/**************************************************************************
**
** UART Communications
**
** Communications is established when the PC communications program sends
** a command character - the particular character sets the mode:
**
** "a" = send all of the realtime display variables (outpc structure) via txport.
** "v" = send all input parameters (inpram structure) via txport.
** "w"+<offset lsb>+<offset msb>+<nobytes>+<newbytes> = 
**    receive an updated input parameter and store in offset location
**    relative to start of inpram structure
** "W" = same as "w" above, followed by "r" below
** "r"+<offset lsb>+<offset msb>+<nobytes>+<newbytes> =
**    send back value of input parameter in offset location
** "B" = jump to flash burner routine and burn all input parameter values in 
**    RAM (inpram structure) into flash (inpflash structure).
** "C" = Test communications - echo back Seconds
** "Q" = Send over Embedded Code Revision Number (divide number by 10 - i.e.
**  $21T is rev 2.1)
**
**************************************************************************/
// rs232 Outputs to pc
typedef struct {
unsigned int16 seconds,pw1,pw2,rpm;           // pw in usec
int16 adv_deg;                                // adv in deg x 10
unsigned int8 squirt,engine,afrtgt1,afrtgt2;    // afrtgt in afr x

/* 
; Squirt Event Scheduling Variables - bit fields for "squirt" variable above
inj1:    equ    0       ; 0 = no squirt; 1 = inj squirting
inj2:    equ    1

; Engine Operating/Status variables - bit fields for "engine" variable above
ready:  equ     0       ; 0 = engine not ready; 1 = ready to run 
                                               (fuel pump on or ign plse)
crank:  equ     1       ; 0 = engine not cranking; 1 = engine cranking
startw: equ     2       ; 0 = not in startup warmup; 1 = in startw enrichment
warmup: equ     3       ; 0 = not in warmup; 1 = in warmup
tpsaen: equ     4       ; 0 = not in TPS acceleration mode; 1 = TPS acceleration mode
tpsden: equ     5       ; 0 = not in deacceleration mode; 1 = in deacceleration mode
mapaen: equ     6       ; 0 = not in MAP acceleration mode 1 = MAP deaceeleration mode
*/

unsigned int8 wbo2_en1,wbo2_en2; // from wbo2 - indicates whether wb afr valid


int16 baro,map,mat;

signed int16 clt;                //coolant temperature in C x 10

int16 tps,batt,ego1,ego2,knock,   // baro - kpa x 10 

                                                 // map - kpa x 10
                                                 // mat, clt deg(C/F)x 10
                                                 // tps - % x 10
                                                 // batt - vlts x 10
                                                 // ego1,2 - afr x 10
                                                 // knock - volts x 10
 egocor1,egocor2,aircor,warmcor,                 // all in %
 tpsaccel,tpsfuelcut,barocor,gammae,             // tpsaccel - acc enrich(.1 ms units)
                                                 // tpsfuelcut - %
                                                 // barcor,gammae - %
 vecurr1,vecurr2,iacstep,cold_adv_deg;           // vecurr - %
                                                 // iacstep - steps
                                                 // cold_adv_deg - deg x 10
signed int16  tpsdot,mapdot;                                   // tps, map rate of change - %x10/.1 sec,
                                                 // kPax10 / .1 sec
int16 coil_dur,                                        // msx10 coil chge set by ecu
//map_acc_en offset is 64 bytes
map_acc_en,tps_acc_en,last_acc,spare1,spare2,
spare3,spare4,spare5,spare6;
} variables_t;

	
typedef struct {
	
unsigned int8 no_cyl,no_skip_pulses,      // skip >= n pulses at startup
    ICIgnOption,     // Bit 0: Input capture: 0 = falling edge, 1 rising
                     // Bit 1: 1= trigger return mode in cranking; for this
          // mode, set bit 0 to normal edge, then opp.edge used in cranking.
          // trigger return not applicable to EDIS
                     // Bits 2-3: spare
	                   // Bits 4-7: 0 = standard - int8ge coil, spark
	                   //           1 = Ford  EDIS option
	                   //           2 = EDIS with multispark
    spkout_hi_lo,    // Ign Output compare: 0 = spark low (gnd)
    max_coil_dur,max_spk_dur,DurAcc;        // ms x 10
int8 deltV_table[NO_COILCHG_PTS],deltDur_table[NO_COILCHG_PTS], // Vx10,msx10
    RevLimOption,     // 0=none, 1=spark retard, 2=fuel cut
    RevLimMaxRtd,     // max amount of spark retard (degx10) (at Rpm2 below)            
    PredOpt;          // Option for prediction algorithm for next tach plse
                      //  0=use last time interval
                      //  1=use 1st deriv prediction; 2=use 1st deriv at hi
                      //   rpm, 2nd deriv prediction at lo rpm;
                      //  3=use 2nd deriv prediction always.
int16 adv_table[NO_SMAPS][NO_SRPMS];
int16 cold_adv_table[NO_TEMPS];
signed  int16 adv_offset;       // all in deg x 10
   //     adv_offset is no deg(x10) between trigger (Input Capture) and TDC.
   //     It may be +btdc (IC1 to TDC) or -atdc (TDC to IC2).
   //
   //    |               |     |
   //    |               |     |
   //   -|---------------|-----|-
   //   IC1             TDC    IC2
int16   RevLimRpm1,RevLimRpm2;  // Optn 1:Retard spk by 0 deg at Rpm1 and increase
                           //    to RevLimMaxRtd at Rpm2
                        // Optn 2:Cut fuel above Rpm2, restore below Rpm1
unsigned int8 ve_table[NO_INJ][NO_FMAPS][NO_FRPMS],  // %
   afr_table[NO_INJ][NO_FMAPS][NO_FRPMS],            // afr x 10
   warmen_table[NO_TEMPS],iacstep_table[NO_TEMPS], // % enrichment vs temp
                                                   // iac steps
   tpsen_table[NO_TPS_DOTS], // accel enrichment pw in .1 ms units vs tpsdot
   mapen_table[NO_MAP_DOTS]; // accel enrichment pw in .1 ms units vs mapdot
unsigned int16 frpm_table[NO_FRPMS],srpm_table[NO_SRPMS];
int16 fmap_table[NO_FMAPS],smap_table[NO_SMAPS],	    // kpa x 10, 
   temp_table[NO_TEMPS],             // deg x 10 (C or F)
   tpsdot_table[NO_TPS_DOTS],        // change in % x 10 per .1 sec
   mapdot_table[NO_MAP_DOTS];        // change in kPa x 10 per .1 sec
int16 map0,mapmax,clt0,cltmult,mat0,matmult,tps0,tpsmax,batt0,battmax,
                  // kPa x 10, deg F or C x 10, adc counts, volts x 10
   ego0,egomult,baro0,baromax,bcor0,bcormult,knock0,knockmax;
                  // afr x 10, kpa x 10, volts x 10
int16 Dtpred_Gain;  // %
unsigned int8 PulseTol,   // % tolerance for next input pulse    
 IdleCtl,         // idle: 0 = none, 1= solenoid, 2= iac stepper motor
                  //  - enabled only when moving, 3 = iac motor - always enabled.
                   // 4 = Ford pwm.
 IACtstep,        // iac stepper motor nominal time between steps (.1 ms units)
 IACaccstep,      // iac stepper motor accel/decel step time (.1 ms)-future use
 IACnaccstep,     // iac stepper motor no. of accel/decel steps - future use
 IACStart;        // no. of steps to send at startup to put stepper 
                  //    motor at reference (wide open) position
int16 IdleHyst;     // amount clt temp must move before Idle position is changed
unsigned int8 CWU,CWH,  // crank pulsewidths at min, max temps in temp_table (ms x 10)
 AWEV,            // after start warmup % enrich add-on value,
 AWC,             // after start enrichment no. of cycles
 Tpsacold,        // cold (-40F) accel amount in .1 ms units
 AccMult,         // cold (-40F) accel multiply factor (%)
 TpsThresh,       // tpsdot threshhold for acc/decel enrichment(change in %x10 per .1 sec) 
 MapThresh,       // mapdot threshhold for acc/decel enrichment(change in kPax10 per .1 s) 
 TpsAsync,        // clock duration (in .1 sec tics) for accel enrichment
 TPSDQ;           // deceleration fuel cut option (%)
int16 TPSWOT,       // TPS value at WOT (for flood clear) in %x10
 TPSOXLimit;      // Max tps value (%x10) where O2 closed loop active
unsigned int8 Tps_acc_wght,    // weight (0-100) to be given to tpsdot for accel enrichment.
                  //  100 - Tps_acc_wght will then be given to mapdot.
 BaroOption,      // 0=no baro, 1=baro is 1st reading of map (before cranking),
                  // 2=independent barometer (=> EgoOption < 3)
 EgoOption,       // 0 = no ego;1= nb o2;2=single wbo2;3=dual wbo2. NOTE:
                  //  BaroOption MUST be < 2 if EgoOption = 3
 EgoCountCmp,     // Ign Pulse counts between when EGO corrections are made
 EgoStep,         // % step change for EGO corrections
 EgoLimit,        // Upper/Lower rail limit (egocorr inside 100 +/- limit)
 AFRTarget,       // NBO2 AFR determining rich/ lean
 Temp_Units;      // 0= coolant & mat in deg F; 1= deg C
int16 FastIdle,     // fast idle Off temperature (idle_ctl = 1 only)
 EgoTemp,         // min clt temp where ego active
 RPMOXLimit;      // Min rpm where O2 closed loop is active
unsigned int16 ReqFuel;     // fuel pulsewidth (usec) at wide open throttle
unsigned int8 Divider,    // divide factor for input tach pulses
 Alternate,       // option to alternate injector banks
 InjOpen,         // Injector open time (.1 ms units)
 InjPWMTim,       // Time (.1 ms units) after Inj opening to start pwm
 InjPWMPd,        // Inj PWM period (us) - keep between 10-25 KHz (100-40 us)
 InjPWMDty,       // Inj PWM duty cycle (%)
 BatFac,          // Battery fuel pw correction factor (msx10)
 EngStroke,       // 0 = 4 stroke
                  // 1 = 2 stroke     
 InjType,         // 0 = port injection
                  // 1 = throttle body
 NoInj,           // no. of injectors (1-12)
 OddFire1,        // > 0 = odd fire option - smaller angle bet firings (deg)
 OddFire2,        // > 0 = odd fire option - larger angle bet firings (deg)
 PrimeP,          // priming pulsewidth (.1 ms units)
 MapAveno,RpmAveno,   // no. of points (Max of 8) for map, rpm rolling averages
 dual_tble_optn,  // 1 = use dual table option - ve, afr tables for each inj
 FuelAlpha,       // option for alpha-N mode: 0=none;1=use map,tps blend algorithm;
                  //   2=same as 1, but don't use kpa multiplier in plsewidth eq.
 IgnAlpha,        // option to use map,tps(alphaN) blend algorithm for ignition
 AfrAlpha,        // option to use map,tps(alphaN) blend algorithm for WBO2 AFR
 cpad1;           // byte pad
int16 alpha_lorpm,  // option to use map,tps(alphaN) blend algorithm for fuel
 alpha_hirpm,     //  use tps if < lorpm; use map if > hirpm; else blend., in which
                  //  case lo, hirpm should be consecutive entries in frpm_table.
                  //    set lorpm=hirpm =0 to use map enrichment only,
                  //    set lorpm =25K to use alpha-N enrichment only,
 alpha_map_table[6][6], // Table of ave map values (kpa x 10) for [tps][rpm]
                  //    pairs. Used only for alpha-N algorithm.
                  //  Allows ve table to retain same ve values
                  //  whether in alpha-N mode or not,
 amap_tps[6];     // Tps values (% x 10) for alpha_map table
unsigned int16 amap_rpm[6];     // Rpm values for alpha_map table
unsigned int32 baud;         // baud rate
int16 MAPOXLimit;   // Max map value (kPax10) where O2 closed loop active
// generic spare port parameters: spr_port = 0(don't use)/1(use),where
// spr_port[0] is PM2,spr_port[1] is PE4; they are set as outs to main pcb;
// out_offset= word(int) offset from start of outpc structure and
// indicates which int variable to be tested for setting port (can't
// use byte variables); condition='<', '>', '='; port_val= value(0/1)
// to which the port will be set when the condition is met:
// <out_offset word>  <condition>  <thresh +/- hyst(eresis)>.
// Hysteresis works as ff: if outpc word > thresh, set port to val and 
// leave until out word < thresh - hyst, then set to 1 - val; 
// similar for <; if outpc word between thresh +/- hyst, set port = val,
// else set to 1 - val. Note: the '=' condition can result in PWM near
// the edges of the band - this is good for warning lights, but may not
// be good for other applications. 
int8 spr_port[NPORT],out_offset[NPORT],condition[NPORT],port_val[NPORT];
int16 thresh[NPORT],hyst[NPORT];
unsigned int8 TpsAsync2, cpad2;  // accel tailoff duration (sec x 10)
int16 TpsAccel2;			// end pulsewidth of accel enrichment (ms x 10)
int16 IACScale;     // scale factor which multiplies IACStart and iacstep_table
int16 inpt_spare[6];  // spares

} inputs_t;

const inputs_t inpflash ={
4,               // no_cyl (1-12)
3,               // no_skip_pulses,  skip >=3 pulses
0x00, 0,         // ICIgnOption,spkout_hi_lo,
31, 20, 6,       // max_coil_dur,max_spk_dur,DurAcc   msx10
{-40,-20,0,20,40},   // deltaV_table[], Vx10 = batt_voltx10 - 120
{24,  9, 0,-5,-9},   // deltaDur_table[], msx10 = correction for batt_volt
1,           // RevLimOption:0,none; 1,retard spk; 2,fuel cut
120,         // RevLimMaxRtd,   deg x 10
2,           // PredOpt	 (For EDIS PredOpt=0 is sufficient)
             // For EDIS keep total adv (incl. offset & cold adv) < 60 deg
{{120,             // adv_table[MAP/tps no=0][RPM no=0], deg x 10
    120,128,145,190,347,360,360,360,360,360,360},
{120,             // adv_table[MAP/tps no=1][RPM no=0], deg x 10
    136,141,152,190,342,360,360,360,360,360,360},
{120,             // adv_table[MAP/tps no=2][RPM no=0], deg x 10
    140,148,172,197,337,360,360,360,360,360,360},
{120,             // adv_table[MAP/tps no=3][RPM no=0], deg x 10
    160,180,200,218,317,340,360,360,360,360,360},
{130,             // adv_table[MAP/tps no=4][RPM no=0], deg x 10
    180,200,220,240,309,325,360,360,360,360,360},
{140,             // adv_table[MAP/tps no=5][RPM no=0], deg x 10
    170,190,216,260,302,310,350,360,360,360,360},
{150,             // adv_table[MAP/tps no=6][RPM no=0], deg x 10
    160,180,202,240,275,295,335,360,360,360,360},
{150,             // adv_table[MAP/tps no=7][RPM no=0], deg x 10
    150,170,190,220,250,280,320,360,360,360,360},
{140,             // adv_table[MAP/tps no=8][RPM no=0], deg x 10
    140,160,180,200,225,265,305,360,360,360,360},
{120,             // adv_table[MAP/tps no=9][RPM no=0], deg x 10
    130,150,170,180,210,250,293,360,360,360,360},
{120,             // adv_table[MAP/tps no=10][RPM no=0], deg x 10
    130,140,160,170,195,235,284,360,360,360,360},
{120,             // adv_table[MAP/tps no=11][RPM no=0], deg x 10
    130,140,150,160,180,220,275,360,360,360,360}},
{60,              // cold_adv_table[TEMP no = 0], deg x 10
   50,40,30,20,10,0,0,0,0},
-100,                // adv_offset,   deg x 10
5500, 6000,       // RevLimRpm1,2
{{{58,            // ve_table[inj1][MAP/tps no =0][RPM no = 0]
   58,59,63,66,68,69,69,69,67,65,63},
{58,              // ve_table[inj1][MAP/tps no =1][RPM no = 0]
   59,63,67,70,73,74,74,73,72,69,67},
{58,              // ve_table[inj1][MAP/tps no =2][RPM no = 0]
   61,65,69,72,75,76,76,76,74,71,69},
{58,              // ve_table[inj1][MAP/tps no =3][RPM no = 0]
   62,67,71,75,77,78,79,78,76,74,71},
{60,              // ve_table[inj1][MAP/tps no =4][RPM no = 0]
   66,71,76,79,82,83,83,82,81,78,75},
{61,              // ve_table[inj1][MAP/tps no =5][RPM no = 0]
   68,73,78,81,84,85,86,85,83,80,78},
{63,              // ve_table[inj1][MAP/tps no =6][RPM no = 0]
   70,75,80,84,86,88,88,87,85,82,80},
{66,              // ve_table[inj1][MAP/tps no =7][RPM no = 0]
   73,79,84,88,91,92,93,92,90,87,84},
{68,              // ve_table[inj1][MAP/tps no =8][RPM no = 0]
   75,81,86,90,93,95,95,94,92,89,86},
{71,              // ve_table[inj1][MAP/tps no =9][RPM no = 0]
   79,85,91,95,98,99,100,99,96,93,90},
{73,              // ve_table[inj1][MAP/tps no =10][RPM no = 0]
   81,87,93,97,100,102,102,101,99,95,92},
{75,              // ve_table[inj1][MAP/tps no =11][RPM no = 0]
   83,89,95,99,103,104,104,103,101,98,94}},
{{58,            // ve_table[inj2][MAP/tps no =0][RPM no = 0]
   58,59,63,66,68,69,69,69,67,65,63},
{58,              // ve_table[inj2][MAP/tps no =1][RPM no = 0]
   59,63,67,70,73,74,74,73,72,69,67},
{58,              // ve_table[inj2][MAP/tps no =2][RPM no = 0]
   61,65,69,72,75,76,76,76,74,71,69},
{58,              // ve_table[inj2][MAP/tps no =3][RPM no = 0]
   62,67,71,75,77,78,79,78,76,74,71},
{60,              // ve_table[inj2][MAP/tps no =4][RPM no = 0]
   66,71,76,79,82,83,83,82,81,78,75},
{61,              // ve_table[inj2][MAP/tps no =5][RPM no = 0]
   68,73,78,81,84,85,86,85,83,80,78},
{63,              // ve_table[inj2][MAP/tps no =6][RPM no = 0]
   70,75,80,84,86,88,88,87,85,82,80},
{66,              // ve_table[inj2][MAP/tps no =7][RPM no = 0]
   73,79,84,88,91,92,93,92,90,87,84},
{68,              // ve_table[inj2][MAP/tps no =8][RPM no = 0]
   75,81,86,90,93,95,95,94,92,89,86},
{71,              // ve_table[inj2][MAP/tps no =9][RPM no = 0]
   79,85,91,95,98,99,100,99,96,93,90},
{73,              // ve_table[inj2][MAP/tps no =10][RPM no = 0]
   81,87,93,97,100,102,102,101,99,95,92},
{75,              // ve_table[inj2][MAP/tps no =11][RPM no = 0]
   83,89,95,99,103,104,104,103,101,98,94}}},
{{{160,             // afr_table[inj1][MAP/tps no =0][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =1][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =2][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =3][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =4][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =5][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =6][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =7][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =8][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =9][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =10][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj1][MAP/tps no =11][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120}},
{{160,             // afr_table[inj2][MAP/tps no =0][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =1][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =2][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =3][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =4][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =5][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =6][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =7][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =8][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =9][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =10][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120},
{160,             // afr_table[inj2][MAP/tps no =11][RPM no = 0], afrx10
    160,150,147,147,147,140,130,120,120,120,120}}},
{170,             // warmen_table[TEMP no = 0],   % enrichment vs temp
    165,160,155,150,135,125,120,110,100},
{40,              // iacstep_table[TEMP no = 0],
  60,75,90,105,120,130,140,150,160}, 
{20,              // tpsen_table[TPS_DOT no = 0], enrichment in .1ms vs tpsdot
  50,105,150}, 
{10,               // mapen_table[TPS_DOT no = 0], enrichment in .1ms vs mapdot
  15,25,35}, 
{500,             // frpm_table[RPM no = 0] , use in VE, AFR tables
  1000,1500,2000,2800,3600,4400,5200,5200,5200,5200,5200},
{500,             // srpm_table[RPM no = 0] , use in spark advance table
  1000,1500,2000,2800,3600,4400,5200,5200,5200,5200,5200},
{200,             // fmap_table[MAP/tps no = 0], kPa x 10 , use for VE, AFR
  300,400,500,600,750,900,1000,1000,1000,1000,1000},
{200,             // smap_table[MAP/tps no = 0], kPa x 10 , use for spk adv
  300,400,500,600,750,900,1000,1000,1000,1000,1000},
{-400,            // temp_table[TEMP no = 0],  deg x 10
     -290,-180,-70,40,160,270,380,540,710},
{100,              // tpsdot_table[TPS_DOT no =0],
  400,800,1540},   //    change in % x 10 per .1 sec
{35,               // mapdot_table[TPS_DOT no =0],
  45,60,70},         //    change in kPa x 10 per .1 sec - max reached is 80 in our hw.
93,              // map0,         kPa x 10, value @ 0 ADC counts
1150,            // mapmax,       kPa x 10, value @ max(1023) ADC counts
0,               // clt0,         deg (C or F) x 10
100,             // cltmult,      %
0,               // mat0,         deg (C or F) x 10
100,             // matmult,      %
0,               // tps0,         adc counts
1023,            // tpsmax,       adc counts
1,               // batt0,        v x 10
234,             // battmax,      v x 10
0,               // ego0,         afr x 10
100,             // egomult,      %
93,              // baro0,        kPa x 10
1150,            // baromax,      kPa x 10
147, -47,        // bcor0,bcormult  kpax10, slope
0,               // knock0,       v x 10
50,              // knockmax,     v x 10
20,              // Dtpred_Gain,  %
50,              // PulseTol,     % tolerance for next input pulse    
0,               // IdleCtl, idle: 0 = none, 1= solenoid, 2= iac stepper motor
                 //  - enabled only when moving, 3 = iac motor - always enabled.
                 // 4 = Ford PWM iac
25,              // IACtstep,  .1 ms units (25 gives pulse freq of 400 Hz)
0,               // IACaccstep
0,               // IACnaccstep
160,             // IACStart,  no. of steps to send at startup to put stepper 
                 //    motor at reference (wide open) position
50,              // IdleHyst amount (degx10)
120, 40,         // CWU,CWH, crank pw at min, max temps in temp_table (ms x 10)
35,              // AWEV, after start warmup % enrich add-on value,
250,             // AWC,  after start enrichment no. of cycles
90,              // Tpsacold,  cold (-40F) accel amount in .1 ms units
100,             // AccMult,   cold (-40F) accel multiply factor (%)
100,             // TpsThresh, tpsdot threshhold for accel enrichment(change in %x10 per .1 s) 
40,              // MapThresh, mapdot threshhold for accel enrichment(change in kPax10 per .1 s) 
15,              // TpsAsync,  clock duration (in .1 sec tics) for accel enrichment
90,              // TPSDQ,  deceleration fuel cut option (%)
700,             // TPSWOT, TPS value at WOT (for flood clear), %x10
700,             // TPSOXLimit,  Max tps value (%x10) where O2 closed loop active
0,               // Tps_acc_wght, weight to be given to tpsdot for accel enrichment.
                 //  100 - Tps_acc_wght will then be given to mapdot.
1,               // BaroOption,  0=no baro, 1=baro is 1st reading of map (before cranking),
                 //   2=independent barometer
1,               // EgoOption,  0 = no ego;1= nb o2;2=single wbo2;3=dual wbo2.
16,              // EgoCountCmp,  Ign Pulse counts between when EGO corrections are made
1,               // EgoStep,   % step change for EGO corrections
15,              // EgoLimit,  Upper/Lower rail limit (egocorr inside 100 +/- limit)
140,             // AFRTarget,  NBO2 afr (afrx10) determining rich/ lean
1,               // Temp_Units,    0= coolant & mat in deg F; 1= deg C
1400,            // FastIdle, fast idle temperature (degx10) (idle_ctl = 1 only)
1600,            // EgoTemp,  min clt temp where ego active, degx10
3400,            // RPMOXLimit,  Min rpm where O2 closed loop is active
3000,            // ReqFuel;  fuel pulsewidth (usec) at wide open throttle
1,               // Divider,   divide factor for input tach pulses injections per cycle
1,               // Alternate,   option to alternate injector banks
10,              // InjOpen,  Injector open time (.1 ms units)
255,             // InjPWMTim,   Time (.1 ms units) after opening to start pwm
66,              // InjPWMPd,    Injector PWM period (us)
75,              // InjPWMDty,   Injector PWM duty cycle (%)
12,              // BatFac,  Battery fuel pw correction factor (msx10)
0,               // EngStroke,  0 = 4 stroke,  1 = 2 stroke     
0,               // InjType,  0 = port injection,  1 = throttle body
4,               // NoInj,    no. of injectors (1-12)
0,0,             // OddFire smaller, larger angle between firings
35,              // PrimeP,   priming pulsewidth (.1 ms units)
2,2,             // MapAveno, RpmAveno   No. points (Max of 8) for averaging
0,               // dual table option
0,               // fuel alpha-N, map blend option
0,               // ign alpha-N, map blend option
0,               // WBO2 AFR alpha-N, map blend option
0,               // byte pad 
0,               // lo rpm for alpha-N, map blend option
0,               // alpha-N hi rpm
{{1000,600,300,350,400,400}, // alpha_map_table[tps no =0][RPM nos 0-5] (kpa x 10)
{1000,650,350,400,450,450}, // alpha_map_table[tps no =1][RPM nos 0-5]
{1000,700,400,450,500,500}, // alpha_map_table[tps no =2][RPM nos 0-5]
{1000,750,450,500,550,550}, // alpha_map_table[tps no =3][RPM nos 0-5]
{1000,800,500,550,600,600}, // alpha_map_table[tps no =4][RPM nos 0-5]
{1000,800,500,550,600,600}}, // alpha_map_table[tps no =5][RPM nos 0-5]
{0,120,160,300,600,600}, // amap_tps[0 - 5] (% x 10);
{0,500,1000,1500,2000,2000},  // amap_rpm[0 - 5]
115200,                   // baud rate
900,          // MAPOXLimit, Max MAP value (kPax10) where O2 closed loop active
{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},  // spare port parameters
1,0,          // accel tail duration (sec x 10)
20,           // accel end pwidth enrichment (ms x 10)
1,            // IAC Scale factor
{0,0,0,0,0,0}     // spares
};
#org default 
